package Service;

import java.util.ArrayList;
import java.util.List;

import dao.PatentDao;
import pojo.PageBean;
import pojo.Patent;

public class PatentService {
	PatentDao cdao;
	public PageBean<Patent> show(int currentPage,int pageSize) {
		cdao = new PatentDao();
		PageBean<Patent> pb = new PageBean<Patent>();
		pb.setList(cdao.PageData(currentPage, pageSize));
		pb.setTotal(cdao.getTotal());
		int totalPage=(cdao.getTotal()%pageSize==0)?(cdao.getTotal()/pageSize):(cdao.getTotal()/pageSize+1);
		pb.setTotalPage(totalPage);
		pb.setCurrentPage(currentPage);
		pb.setPageSize(pageSize);
		return pb;
	}
	public List<Patent> showPatentByType(int currentPage,int pageSize,int id){
		cdao = new PatentDao();
		List<Patent>list=new ArrayList<Patent>();
		list=cdao.showPatentByType(currentPage, pageSize, id);
		return list;
	}
	public int add(Patent p) {
		cdao=new PatentDao();
		int flag=cdao.add(p);
		return flag;
	}
}